package com.qing.design.patterns.builder.example.director;

import com.qing.design.patterns.builder.example.builders.Builder;
import com.qing.design.patterns.builder.example.cars.CarType;
import com.qing.design.patterns.builder.example.components.Engine;
import com.qing.design.patterns.builder.example.components.GPSNavigator;
import com.qing.design.patterns.builder.example.components.Transmission;
import com.qing.design.patterns.builder.example.components.TripComputer;

/**
 * 主管导义了建筑步骤的顺序。
 * 它通过公共生成器接口处理生成器对象。
 * 因此，它可能不知道正在制造什么产品。
 */
public class Director {

	/**
	 * 构建跑车
	 * @param builder
	 */
	public void constructSportsCar(Builder builder){
		builder.setCarType(CarType.SPORTS_CAR);
		builder.setSeats(2);
		builder.setEngine(new Engine(3.0,0));
		builder.setTransmission(Transmission.SEMI_AUTOMATIC);
		builder.setTripComputer(new TripComputer());
		builder.setGpsNavigator(new GPSNavigator());
	}

	/**
	 * 施工车
	 * @param builder
	 */
	public void constructCityCar(Builder builder) {
		builder.setCarType(CarType.CITY_CAR);
		builder.setSeats(2);
		builder.setEngine(new Engine(1.2, 0));
		builder.setTransmission(Transmission.AUTOMATIC);
		builder.setTripComputer(new TripComputer());
		builder.setGpsNavigator(new GPSNavigator());
	}

	/**
	 * SUV
	 * @param builder
	 */
	public void constructSUV(Builder builder) {
		builder.setCarType(CarType.SUV);
		builder.setSeats(4);
		builder.setEngine(new Engine(2.5, 0));
		builder.setTransmission(Transmission.MANUAL);
		builder.setGpsNavigator(new GPSNavigator());
	}
}
